package com.iflytek.iot.platform;

import cn.zull.tracing.core.dto.TraceDTO;
import cn.zull.tracing.core.model.DefaultTraceLog;
import cn.zull.tracing.core.model.TraceStatusEnum;
import com.alibaba.fastjson.JSON;
import com.iflytek.iot.platform.tracing.constant.Constants;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Map;

/**
 * @author zurun
 * @date 2019/2/15 23:41:33
 */
@Data
@Accessors(chain = true)
public class IotTraceLogEntity extends DefaultTraceLog {
    private transient TraceDTO traceDTO;
    private transient Long startTime;

    private String traceId;
    private String spanId;
    private String osid = Constants.IOT;
    /**
     * 链路类型
     */
    private String traceType;
    /**
     * 主机信息 ip:port
     */
    private String endPoint;
    /**
     * 远程地址
     */
    private String url;

    /**
     * 链路创建时间(时间戳,ms)
     */
    private String ctm;
    /**
     * 链路时长
     */
    private String cost;
    /**
     * 请求耗时
     */
    private String utm;
    /**
     * 开始时间 2018-09-24 18:12:13
     */
    private String stm;
    /**
     * 结束时间
     */
    private String etm;
    /**
     * 链路是否成功
     */
    private TraceStatusEnum status = TraceStatusEnum.SUCCESS;

    /**
     * iot平台要求，必传字段
     */
    private String cpname = "iotPlatform";
    /**
     * 读取配置文件:tracing.user-defined.type
     */
    private String type;

    /**
     * 必传字段
     */
    private String localip;
    /**
     * 配置项:tracing.user-defined.room，必传字段
     */
    private String room;
    private String podid;
    private String remoteip;
    private String reqadd;
    private String retcode=Constants.RETCODE_SUCCESS;
    private String retdesc=Constants.RETDESC_SUCCESS;
    private String cmd;
    private String reqpkg;
    private String inner;
    private String respkg;

    // iot业务需要
    private String deviceid;
    private String ctei;
    private String caller;
    private String uid;
    private String sequenceNo;
    private String manufacturer;
    private String brandname;
    private String model;
    private String category;

    /**
     * 第三方id
     */
    private String devicesn;

    private String platform;

    public Map<String, String> toMap(){
        Map<String,String> map=JSON.parseObject(JSON.toJSONString(this),Map.class);
        return map;
    }
}
